package com.atguigu.chapter05.transform;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.ConnectedStreams;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.co.CoMapFunction;

/**
 * Author: Pepsi
 * Date: 2023/7/28
 * Desc:
 */
public class Flink09_union {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port",1000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);

        DataStreamSource<Integer> s1 = env.fromElements(1, 2, 3);
        DataStreamSource<Integer> s2 = env.fromElements(11, 22, 33);
        DataStreamSource<Integer> s3 = env.fromElements(111, 222, 333);

        DataStream<Integer> unionSource = s1.union(s2, s3);

        unionSource
                .map(new MapFunction<Integer, String>() {
                    @Override
                    public String map(Integer value) throws Exception {
                        return value + "  -_-!";
                    }
                })
                .print();

        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
